from sitepal.sitebase.models                import Resource,ResourceTree
from sitepal.sitebase.tests.models.entities import EntityTest
from sitepal.sitebase.tests.models.trees    import TreeTest

class ResourceTest(EntityTest):
    def create_object(self,obj,save=True,**kwargs):
        self.assertTrue(isinstance(obj,Resource))
        obj.name = kwargs['name']
        obj      = EntityTest.create_object(self,obj,save=save,**kwargs)
        return obj

    def verify_object(self,obj,**kwargs):
        self.assertTrue(isinstance(obj,Resource))
        EntityTest.verify_object(self,obj,**kwargs)
        self.assertTrue(obj.name == kwargs['name'])

class ResourceTreeTest(ResourceTest,TreeTest):
    def create_object(self,obj,save=True,**kwargs):
        self.assertTrue(isinstance(obj,ResourceTree))
        obj = ResourceTest.create_object(self,obj,save=False,**kwargs)
        obj = TreeTest.create_object(self,obj,save=False,**kwargs)
        return self.save_object(obj,save=save)

    def verify_object(self,obj,**kwargs):
        self.assertTrue(isinstance(obj,EntityTree))
        ResourceTest.verify_object(self,obj,**kwargs)
        TreeTest.verify_object(self,obj,**kwargs)

